package com.untrance.shop.core.dao;

import java.util.Collection;
import java.util.List;

import javax.persistence.EntityManager;

import com.google.appengine.api.datastore.Key;
import com.untrance.shop.common.filters.model.Filter;
import com.untrance.shop.model.MainEntity;

/**
 * @author eugene zadyra
 */
public interface MainDao <U extends MainEntity>{
	
	EntityManager getEntityManager();
	
	U find(Key id);
	
	Collection<U> findAll();
	
	Integer countAll();
	
	<T extends MainEntity> T add(T object);
	
	<T extends MainEntity> T update(T object);
	
	void remove(Key id);
	
	int removeAll();

	Collection<U> findEntitiesByKeyCollection(Collection<Key> keys);

	<F extends Filter> List<U> findEntitiesByFilter(F filter);

	<F extends Filter> Integer findEntitiesCountByFilter(F filter);
}
